package com.lxy.cxcyxmmsbackend.sys.controller;


import com.lxy.cxcyxmmsbackend.sys.entity.QxglRole;
import com.lxy.cxcyxmmsbackend.sys.req.PageReq;
import com.lxy.cxcyxmmsbackend.sys.res.Result;
import com.lxy.cxcyxmmsbackend.sys.service.QxglRoleService;
import com.lxy.cxcyxmmsbackend.sys.utils.JwtUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 角色管理
 * @author 刘新颖
 * @since 2024-01-07
 */
@Api(tags = "权限管理_角色")
@RestController
@RequestMapping("/qxglRole")
public class QxglRoleController {

    @Resource
    QxglRoleService qxglRoleService;

    @RequestMapping("selectRole")
    public Result selectRole(@RequestBody PageReq pageReq) {
        return qxglRoleService.selectRole(pageReq.getKeyWord().get("rolemc"));
    }

    @RequestMapping("selectRoleNoByRId")
    public Result selectRoleNoByRId(@RequestHeader("token") String token) {
        return qxglRoleService.selectRoleNoByUid(JwtUtil.getUserName(token));
    }

    @RequestMapping("insertRole")
    public Result insertRole(@RequestBody QxglRole qxglRole) {
        return qxglRoleService.insertRole(qxglRole);
    }

    @RequestMapping("updateRole")
    public Result updateRole(@RequestBody QxglRole qxglRole) {
        return qxglRoleService.updateRole(qxglRole);
    }

    @RequestMapping("deleteRole/{roleBh}")
    public Result deleteRole(@PathVariable("roleBh") String roleBh) {
        return qxglRoleService.deleteRole(roleBh);
    }

}

